<?php

namespace App\Http\Controllers\Admin\miniapp;

use App\Http\Controllers\Controller;
use App\Models\miniapp\Setting;

class SettingsController extends Controller
{
    public function index()
    {
        $settings = Setting::pluck('value', 'key');
        return $this->successful($settings);
    }

    public function update()
    {
        $data = request()->all();
        foreach ($data as $key => $value) {
            Setting::where('key', $key)->update(['value' => $value]);
        }
        return $this->successful([], '更新成功');
    }
}
